define(function(require, exports, module) {
	"require:nomunge,exports:nomunge,module:nomunge";

	var app = require('mokit/app');
	var ProjectListView = require('../views/provider');
	var commonUtils = require('../common/utils');
	var Provider = require('../models/Provider');
	var Works = require('../models/Works');
	var Project = require('../models/Project');	
	var model;

	/**
	 * 社友录页面控制器
	 */
	return app.controller.create({
		isSetting: true,
		/**
		 * 默认action
		 */

		index: function(context) {
			var self = this;
			var type = context.routeData.type || "provider";
			model = type=="provider" ? Provider : Works;

			model.iniList(function(){
				Project.getCatList(function(callback){
					model.catList = Project.catList;
					self.setView(new ProjectListView({
						model: model
					}));	
				});
			});	
		},
		//排序列表
		sortList: function(context, sortBy) {
			model.sortList(sortBy, function() {
				context.view.render();
			});
		},
		//筛选列表
		filterList: function(context, type, val) {
			model.filterList(type, val, function() {
				context.view.render();
			});
		},
		//跳转
		jump: function(context,uri) {
			app.start(uri,0);
		}
	});

});